package com.stujyh;

public class WeaponFactory {
    /***
     * 获取武器
     * @param weapon
     */
    public static Weapon getWeapon(String weapon) {
        if ("Tank".equals(weapon)) {
            return new Tank();
        } else if ("Gun".equals(weapon)) {
            return new Gun();
        } else {
            throw new RuntimeException("没有该类型的武器");
        }
    }
}
